<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<HTML>
	<HEAD>
		<meta http-equiv="Content-Language" content="zh-cn">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="${pageContext.request.contextPath}/css/Style1.css" rel="stylesheet" type="text/css" />
		<style>
			body{
				position: relative;
			}
            .pj{
                margin-top: 60px;
                width: 250px;
                background: #f9f29f;
                /*border: 1px solid #269abc;*/
                box-shadow: #1D222D;
				overflow-y: auto;
            }
            .pj img{
                width: 50px;
                height: 70px;
                margin: 2px;
                padding: 2px;
            }
            .pj textarea{
                overflow-y: auto;
            }
            .pj .btn{
				width: 20px;
                text-align: center;
                border-radius: 2px;
                background: #2e6da4;
            }
			.pj .removePj{
				float: right;
				width: 20px;
				height: 20px;
				background: grey;
				color: red;
			}
			.pj .removePj:hover{
				cursor: pointer;
			}
            .pj .btn:hover{
                cursor: pointer;
            }
		</style>
		<script language="javascript" src="${pageContext.request.contextPath}/js/jquery-2.0.3.min.js"></script>
		<%--<script language="javascript" src="${pageContext.request.contextPath}/js/public.js"></script>--%>
		<script type="text/javascript">
            // var i=0;
			function showDetail(oid) {
			    console.log(oid);
			    /*var str = "#div"+oid;
			    console.log($("#btn"+oid).innerText);*/
			    /*if()*/
			    $("#divmask").css({
					'display':'block',
					'position':'absolute',
					'width':'100%',
					'height':'100%',
					'background':'rgba(0,0,0,0.3)'
				});
				$.ajax({
					type:'POST',
					url:'/admin/adminOrderItem_findById',
					data:JSON.stringify({'oid':oid}),
					// dataType:'json',
					contentType:'application/json;charset=utf-8',
					success:function (msg) {
					    var string = [];
						for (var i=0;i<msg.length;i++){
                            console.log(msg[i].product.pname);
						    string[i] = '<span style="display: block;">订单项:'+msg[i].itemid+'</span>'+
                                	'<span style="display: block;"><img src="/'+msg[i].product.image+'" title="'+msg[i].product.pname+'"></span>'+
									'<span style="display: block;">'+'商品评价:'+(msg[i].evaluation==null?"还未评论":msg[i].evaluation)+'</span>'+
									'<span style="display: block;">'+'服务评价:'+(msg[i].gwpj==null?"还未评论":msg[i].gwpj)+'</span>'+
									'<span style="display: block;">'+'客服评价:'+(msg[i].kfpj==null?"还未评论":msg[i].kfpj)+'</span>'+
									'<span style="display: block;">'+'物流评价:'+(msg[i].wlpj==null?"还未评论":msg[i].wlpj)+'</span>';
						    // if(null!=msg[i].evaluation)
						    	if(null==msg[i].huifu||""==msg[i].huifu){
                                    string[i] += '<span style="display: block;">回复评价:'+'<textarea class="text'+msg[i].itemid+'"></textarea></span>'+
                                        '<span class="btn" onclick="storeHuiFu('+msg[i].itemid+')">确定</span>';
								}else {
						            string[i] += '<span style="display: block;">回复评价:'+'<textarea>"'+msg[i].huifu+'"</textarea></span>';
								}
						}
						var content = '<div class="pj"><span class="removePJ" onclick="removePj()">X</span>' + string + '</div>';
						$("#divmask").html(content);
                    }
				})
            }
            
            function storeHuiFu(itemid) {
                // var $text = $(".pj textarea").val();
                var $text = $(".text"+itemid).val();
                console.log(itemid+' '+$text);
                $.ajax({
					type:'POST',
					url:'/addRespon',
					data:JSON.stringify({itemid:itemid,huifu:$text}),
                    async:true,
                    contentType:'application/json;charset=utf-8'
				})
                $("#divmask").css("display","none");
            }

            function removePj() {
                $("#divmask").css("display","none");
            }

		</script>
	</HEAD>
	<body >
		<br>
		<form id="Form1" name="Form1" action=" " method="post">
			<table cellSpacing="1" cellPadding="0" width="100%" align="center" bgColor="#f5fafe" border="0">
				<TBODY>
					<tr>
						<td class="ta_01" align="center" bgColor="#afd1f3">
							<strong>订单 列 表</strong>
						</TD>
					</tr>
					<tr>
						<td class="ta_01" align="center" bgColor="#f5fafe">
							<table cellspacing="0" cellpadding="1" rules="all"
								bordercolor="gray" border="1" id="DataGrid1"
								style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; WIDTH: 100%; WORD-BREAK: break-all; BORDER-BOTTOM: gray 1px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #f5fafe; WORD-WRAP: break-word">
								<tr
									style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 25px; BACKGROUND-COLOR: #afd1f3">

									<td align="center" width="18%">
										订单序号
									</td>
                                    <td align="center" width="18%">
                                        订单编号
                                    </td>
									<td align="center" width="17%">
										总金额
									</td>
									<td width="7%" align="center">
										收货人
									</td>
									<td width="7%" align="center">
										订单状态
									</td>
									<td width="7%" align="center">
										订单详情
									</td>
								</tr>
								<%--<s:iterator var="c" value="cList" status="status">--%>
								<c:forEach items="${requestScope.orderPageUtils.list}" var="order" varStatus="status">
										<tr onmouseover="this.style.backgroundColor = 'white'"
											onmouseout="this.style.backgroundColor = '#F5FAFE';">
											<td style="CURSOR: hand; HEIGHT: 22px" align="center"
												width="10%">
												${status.count}
												<%--<s:property value="#status.count"/>--%>
											</td>
                                            <td style="CURSOR: hand; HEIGHT: 22px" align="center"
                                                width="10%">
                                                    ${order.oid}
                                                    <%--<s:property value="#status.count"/>--%>
                                            </td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center"
												width="17%">
												<%--<s:property value="#c.cname"/>--%>
												${order.total}
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center"
												width="17%">
													<%--<s:property value="#c.cname"/>--%>
													${order.name}
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center"
												width="17%">
													<c:if test="${order.statu==1}">
														未付款
													</c:if>
												<c:if test="${order.statu==2}">
													<a href="/sendProduct?oid=${order.oid}">发货</a>
												</c:if>
												<c:if test="${order.statu==3}">
													未确认收货
												</c:if>
												<c:if test="${order.statu==4}">
													交易完成
												</c:if>
											</td>
											<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="*">
                                                <input id="btn${order.oid}" type="button" value="订单详情" onclick="showDetail(${order.oid})"/>
											</td>
											<div id="divmask"></div>
										</tr>
								</c:forEach>
									<%--</s:iterator>	--%>
							</table>
							<%--分页按钮--%>
							<div class="pagination">
								<span>第<input style="width: 20px" type="text" name="curPage" value="${requestScope.orderPageUtils.page}" maxlength="3"/>/${requestScope.orderPageUtils.totalPage}页</span>
								<a href="/admin/adminOrder_findAllByPage?page=1" class="firstPage">&nbsp;首页</a>
								<c:if test="${requestScope.orderPageUtils.page!=1}">
									<a href="/admin/adminOrder_findAllByPage?page=${requestScope.orderPageUtils.page-1}" class="previousPage">&nbsp;上一页</a>
								</c:if>
								<c:if test="${requestScope.orderPageUtils.page!=requestScope.orderPageUtils.totalPage}">
									<a href="/admin/adminOrder_findAllByPage?page=${requestScope.orderPageUtils.page+1}" class="previousPage">&nbsp;下一页</a>
								</c:if>
								<a href="/admin/adminOrder_findAllByPage?page=${requestScope.orderPageUtils.totalPage}" class="firstPage">&nbsp;末页</a>
							</div>
						</td>
					</tr>
				</TBODY>
			</table>
		</form>
	</body>
</HTML>

